package com.hu.common.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @Author: 63198
 * @Date: 2019/5/21 9:25 PM
 * @Version 1.0
 */
@Component
public class Config {


    /**
     * 直接放行的URL
     * 此处的放行是指在登录后的放行
     * 所以前提条件是已经登录
     * 登录前放行的在security/SpringSecurityConfig里面进行配置
     */
    public static String[] ignoreUris = new String[]{
            "/i==ALL",
            "/avatar==ALL",
            "/resourceAuthorityTree==GET",
            "/reLogin==POST",
    };

    public static Integer userTokenDuration = 10 ;

    public static Integer captchaTokenDuration = 30 ;

    public static String apiVersion ;

    public static Integer maxPageSize ;

    @Value("${server.api-version}")
    public void setApiVersion(String apiVersion){
        Config.apiVersion = apiVersion;
    }


    @Value("${spring.jwt.user-token-duration}")
    public void setUserTokenDuration(String userTokenDuration){
        Config.userTokenDuration = Integer.parseInt(userTokenDuration,10);
    }

    @Value("${spring.jwt.captcha-token-duration}")
    public void setCaptchaTokenDuration(String captchaTokenDuration){
        Config.captchaTokenDuration = Integer.parseInt(captchaTokenDuration,10);
    }

    @Value("${spring.max-page-size}")
    public void setMaxPageSize(String maxPageSize){
        Config.maxPageSize = Integer.parseInt(maxPageSize,10);
    }
}
